package Practice06.test3;

import java.util.Scanner;

public class ExceptionTest3 {

    public EmailException checkEmail(String str){
        EmailException exception = null;
        if (!str.contains("@")){
            exception = new EmailException("邮件地址中没有@");
        } else if (str.lastIndexOf("@") <= 5) {
            exception = new EmailException("@符号前至少需要6位");
        }
        return exception;
    }

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String email = sc.nextLine();
        try {
            EmailException exception = new ExceptionTest3().checkEmail(email);
            if (exception != null){
                throw exception;
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
